home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / QuickDraw™ GX v1.0ß2 / Sample Code / Graphics Samples / Text To Outlines ƒ / Text To Outlines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-14  |  4.1 KB  |  142 lines  |  [TEXT/KAHL]

  1. /**
  2.     Text To Outlines.c
  3.     
  4.     This application will create a gxLine of text, and convert it to a gxPath gxShape. By changing the
  5.     sample to a gxPath will give you the outlines of each character. 
  6.     
  7.     
  8.     NOTES:
  9.     • This file requires the following files to run correctly:
  10.         "graphics shell.c", "Font library.c", "graphics debug library.c", "Transform library.c".
  11.  
  12.     • This file prints the "best" in landscape mode.
  13.     
  14.     ©1990-1993  Apple Computer, Inc.
  15.     All rights reserved.
  16. **/
  17.  
  18. #include <Events.h>
  19. #include <Windows.h>
  20.  
  21. #include "graphics libraries.h"
  22. #include "graphics toolbox.h"
  23. #include "Font library.h"
  24. #include "graphics shell.h"
  25.  
  26.  
  27. //
  28. //  Set up the title and size of the window 
  29. //
  30. Str255         gWindowTitle = "\p Text To Outlines ";         
  31. Rect         gWindowQDRect  = {50, 10, 280, 460};
  32.  
  33. //
  34. //    If gDebugging = TRUE, graphics library errors and notices will be posted.  This functionality  will only work with 
  35. //    the "debugging" version of the Secret Graphics init.  If this version of the init is not installed, nothing bad will happen, 
  36. //    but these  functions will not work. The "debugging" version of the Secret  Graphics init is approximately 700K.
  37. //
  38. Boolean        gDebugging = true;
  39.  
  40.  
  41. //
  42. //     Set  "gGiveMeValidation" to TRUE, if you will receive run-time validation.  
  43. //
  44. Boolean        gGiveMeValidation = true;
  45.  
  46.  
  47. //
  48. //    gGraphicsHeapSize sets the size of the graphics gxHeap created by calling the GXNewGraphicsClient routine
  49. //    in main () within graphics shell.c.  You can determine the amount of graphics gxHeap required by using GraphicsBug.
  50. //    With  gGraphicsHeapSize set to 15k, I had 4 free blocks left in the graphics gxHeap. Sounds good to me.
  51. //
  52. long        gGraphicsHeapSize = 75;
  53.  
  54. gxShape         gTextOutlineShape;
  55.  
  56.  
  57.  
  58. /*------ DoInitialization ---------------------------------------------------------------------------------*/
  59.  
  60. void DoInitialization(aWindow)
  61. WindowPtr aWindow;
  62. {
  63.     gxPoint    textPostion;
  64.     gxColor     textOutlineColor;
  65.     
  66.     //
  67.     //    Set up the starting text postion. This location will be set up when we
  68.     //    create our text gxShape.
  69.     //
  70.     textPostion.x = ff(30);
  71.     textPostion.y = ff(150);
  72.     
  73.     //
  74.     //  Create the text, and set the gxFont and size.
  75.     //
  76.     gTextOutlineShape = GXNewText(5,(unsigned char*)"Waves", &textPostion);
  77.     SetShapeCommonFont(gTextOutlineShape, timesFont);
  78.     GXSetShapeTextSize(gTextOutlineShape, ff(145));
  79.  
  80.     GXSetShapeType(gTextOutlineShape, gxPathType);
  81.     GXSetShapeFill(gTextOutlineShape, gxClosedFrameFill);
  82.     GXSetShapePen(gTextOutlineShape, ff(2));
  83.     GXSetShapeStyleAttributes(gTextOutlineShape, gxOutsideFrameStyle);
  84.  
  85.     
  86.     //
  87.     //    A gxColor, to run through hsv space with... 
  88.     //
  89.     textOutlineColor.space                     = gxHSVSpace;
  90.     textOutlineColor.profile                 = nil;
  91.     textOutlineColor.element.hsv.hue         = 0xD4DA;
  92.     textOutlineColor.element.hsv.saturation = 0xD657;
  93.     textOutlineColor.element.hsv.value         = 0xFFFF;
  94.  
  95.     GXSetShapeColor(gTextOutlineShape, &textOutlineColor);
  96. }
  97.  
  98.  
  99.  
  100. /*------ DoDraw ---------------------------------------------------------------------------------------*/
  101.  
  102. void DoDraw(aWindow)
  103. WindowPtr aWindow;
  104. {
  105.     GXDrawShape (gTextOutlineShape);
  106. }
  107.  
  108.  
  109. /*------ DoDispose -------------------------------------------------------------------------------------*/
  110.  
  111. void DoDispose(aWindow)
  112. WindowPtr aWindow;
  113. {
  114.     //  
  115.     //    You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good 
  116.     //    form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
  117.     //    call to DisposeWindow should dispose of the objects. If you are running the debugging version of the 
  118.     //    SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
  119.     //    can turn notices on in this file by setting gDebugging = TRUE (above).
  120.     //
  121.     GXDisposeShape(gTextOutlineShape);  
  122.     GXDisposeShape(gWindowBoundsShape);  
  123.        DisposeWindow(aWindow);
  124. }
  125.     
  126.  
  127.  
  128. /*------ DoClick ---------------------------------------------------------------------------------------*/
  129.  
  130. void DoClick(aWindow)
  131. WindowPtr aWindow;
  132. {
  133. }
  134.  
  135.  
  136. /*------ DoIdle ----------------------------------------------------------------------------------------*/
  137.  
  138. void DoIdle(aWindow)
  139. WindowPtr aWindow;
  140. {
  141. }
  142.